package cn.karent.adapter;

import cn.karent.common.Result;
import cn.karent.domain.FileService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 文件上传接口
 *
 * @author wanshengdao
 * @date 2025/4/19
 */
@Slf4j
@RestController
@RequiredArgsConstructor
public class FileController {

    private final FileService fileService;

    @PostMapping("/upload")
    public Result<String> upload(@RequestParam(defaultValue = "default") String dir, MultipartFile file) {
        return Result.ok(fileService.upload(dir, file));
    }

}
